
const path = require('path');
const { extendDefaultPlugins } = require('svgo');

function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
  publicPath: './',
  devServer: {
    open: true, // 启动服务后是否打开浏览器
    disableHostCheck: true
  },
  configureWebpack: {
    resolve: {
        alias: {
            '@': resolve('src'),
            '@c': resolve('src/components'),
            '@u': resolve('src/utils'),
            '@as': resolve('src/assets'),
        }
    },
},
chainWebpack(config) {
  config.plugin('html')
      .tap(args => {
          args[0].title = '可视化数据大屏' // 默认title
          return args
      })
      .end()

  // set svg-sprite-loader

  config.module
      .rule("svg")
      .exclude.add(resolve("src/icons"))
      .end();
  config.module
      .rule("icons")
      .test(/\.svg$/)
      .include.add(resolve("src/icons"))
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
          symbolId: "icon-[name]",
      })
      .end()
      .use('svgo-loader').loader('svgo-loader')
      .tap(options => ({
          ...options,
          plugins: extendDefaultPlugins([
              {
                  name: 'removeAttrs',
                  params: {
                      attrs: 'fill'
                  }
              }
          ])
      }))
      .end();
},
}